package Test;

import java.math.BigDecimal;

public class Demo01 {

    public boolean isZhi(int a) {
        int i = 2;
        for (; i <= a; i++) {
            if (a % i == 0 && a != i) {
                return false;
            }
        }
        if (i >= a / 2)
            return true;
        else
            return false;
    }

    public void test(int a) {
        System.out.print(a + "=");
        int i = 2;
        while (true) {
            if (isZhi(i)) {
                if (a % i == 0 && a / i == 1) {
                    System.out.print(i);
                    break;
                }
                if (a % i == 0) {
                    a = a / i;
                    System.out.print(i + "*");
                    i = 2;
                    continue;
                }
            }
            i++;
        }
    }


    public void Out() {
        int one;
        int two;
        for (int i = 0; i <= 100000; i++) {
            one = (int) Math.sqrt(100 + i);
            two = (int) Math.sqrt(168 + i);
            if (one * one == 100 + i && two * two == 168 + i) {
                System.out.print(i + "\t");
            }
        }
    }

    private static int ima;

    public static void main(String[] args) {

        int failureRecord = 20;
        double successPercent = 0.8d;

        /**
         * 由于精度不准，在这里不能使用double 或者float这样的数据类型来做
         * 需要使用专门的高精度计算来实现
         */
        System.out.println(100 * (1 - successPercent));
        System.out.println(failureRecord > 100 * (1 - successPercent));

        System.out.println("===================");
        int i = Integer.numberOfLeadingZeros(0b01010001000100100100100000000000);

        System.out.println(i);


        System.out.println(tableSizeFor(6 + (6 / 2 + 1)));
    }


    private static final int tableSizeFor(int c) {
        int n = c - 1;
        n |= n >>> 1;
        n |= n >>> 2;
        n |= n >>> 4;
        n |= n >>> 8;
        n |= n >>> 16;
        return (n < 0) ? 1 : (n >= (1 << 29)) ? 1 << 30 : n + 1;
    }
}
